<template>
	<view class="">
		<my-dropdown-filter 
			:filterData='filterData' 
			:defaultIndex='defaultIndex'
		  @onSelected='onSelected' 
			@dateChange='dateChange'>
		</my-dropdown-filter>
		<u-gap height="51" />
		<view class="my-list">
			<u-list :height="swiperHeight" @scrolltolower="scrolltolower" v-if="dataList.length > 0">
				<u-list-item v-for="(orderIm, orderIx) in dataList" :key="orderIx">
					<view class="item lh-44">
						<view class="border-b pb-20 flex justify-between align-center">
							<view>
								<view class="flex align-center">
									<text class="mr-20 bg-cyan border-radius-6 fsize-26 pt-2 pb-2 pl-8 pr-8">实际{{orderIm.direction===1?'收入':'支出'}}</text>
									<text>{{orderIm.explain}}</text>
								</view>
								<view class="fsize-26 line-gray">{{orderIm.createTime}}</view>
							</view>
							<view class="text-align-right">
								<view class="line-red">
									<text class="fsize-22">￥</text>
									<text>{{orderIm.orderAmount}}</text>
								</view>
								<view class="line-gray fsize-26">{{orderIm.paymentName}}</view>
							</view>
						</view>
						<view class="pt-20 flex justify-between align-center line-gray fsize-26">
							<view>
								<view>{{orderIm.sysUserName || orderIm.userName}}</view>
								<view>{{orderIm.orderId}}</view>
							</view>
							<text>{{orderIm.orderText}}</text>
						</view>
					</view>
				</u-list-item>
				<u-loadmore :status="loadmore.status" :icon-type="loadmore.iconType" :load-text="loadmore.loadText.loadText" margin-top="20"
					margin-bottom="20" class="coreshop-padding-top-10" />
			</u-list>
		</view>
		<!-- 无数据时默认显示 -->
		<view class="emptybox" v-if="dataList.length == 0">
			<u-empty icon-size="150" text="暂无数据" mode="data"></u-empty>
		</view>
	</view>
</template>

<script>
	import myDropdownFilter from '@/components/my-dropdown-filter/my-dropdown-filter.vue'
	import listHeightMixin from '@/common/computedAltitude.js'
	export default {
		mixins:[listHeightMixin],
		components:{
			myDropdownFilter
		},
		data() {
			return {
				filterData:[
					{
						title:'类型',
						type: 'select',
						items:[
							{ text: '全部', value: 0 }, 
							{ text: '产品订单支付', value: 1 }, 
							{ text: '项目订单支付', value: 11}, 
							{ text: '卡项订单支付', value: 12 },
							{ text: '余额充值支付', value: 13 },
							{ text: '联创入股充值', value: 14 },
							{ text: '财务记录', value: 15 },
						]
					},
					{
						title:'标签',
						type: 'select',
						items:[
							{ text: '全部', value: '' },
							{ text: '微信支付', value: 'wechatpay' }, 
							{ text: '支付宝支付', value: 'alipay' }, 
							{ text: '线下支付', value: 'offline' },
							{ text: '余额支付', value: 'balancepay' },
							{ text: '股本消费', value: 'stockpay' },
						]
					},
					{
						title:'时间',
						type: 'dateRange',
						items:[]
					}
				],
				defaultIndex:[0,0],
				loadmore:{
					status: 'loadmore',
					iconType: 'flower',
					loadText: {
						loadmore: '轻轻上拉',
						loading: '努力加载中',
						nomore: '实在没有了'
					},
				},
				dataList: [],
				searchData: {
					financialType: 0,
					createTime:'',
					paymentCode:'',
					page: 1,
					limit: 30
				}
			}
		},
		onLoad() {
			this.getPageList()
			uni.$on('upFinancialList', ()=>{
				this.queryList()
			})
		},
		onUnload() {
			uni.$off('upFinancialList')
		},
		methods: {
			dateChange(date){
				this.searchData.createTime = date
				this.queryList()
			},
			onSelected(vls){
				this.searchData.financialType = vls[0].value
				this.searchData.paymentCode = vls[1].value
				this.queryList()
			},
			queryList(){
				this.searchData.page = 1
				this.dataList = []
				this.getPageList()
			},
			getPageList() {
				this.$reqPost('FinanceAccountGetPageList', this.searchData).then(res => {
					this.dataList = [...this.dataList, ...res.data]
					if (res.count > this.dataList.length) {
						this.loadmore.status = 'loadmore'
						this.searchData.page++
					} else {
						// 数据已加载完毕
						this.loadmore.status = 'nomore'
					}
				})
			},
			scrolltolower() {
				if (this.loadmore.status === 'loadmore') {
					this.getPageList()
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	
</style>
